Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

316
Visualizações
How to solve "TypeError: $(...).length is not a function"?

My code is like this :

$(document).ready(function () {
    size_li = $("#myList li").length();
    x=3;
    $('#myList li:lt('+x+')').show();
    $('#loadMore').click(function () {
        x= (x+5 <= size_li) ? x+5 : size_li;
        $('#myList li:lt('+x+')').show();
    });
    $('#showLess').click(function () {
        x=(x-5<0) ? 3 : x-5;
        $('#myList li').not(':lt('+x+')').hide();
    });
});

Or see demo and full code here : http://jsfiddle.net/oscar11/6FzSb/4177/

I use jquery 3.0.1

When executed, there exist error :

TypeError: $(...).length is not a function

How can I solve it?

about 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Instead of this

$("#myList li").length();

Use this:

$("#myList li").length;

The $("#myList li") returns an array like object. All array like objects have a property called length, which when be read returns the number of items contained in the array like object. That being said there isn't any function called length. Hence length() is meaningless.

about 4 years ago · Santiago Trujillo Relatório

0

length is a property, not a function, so remove the ()

$("#myList li").length;
about 4 years ago · Santiago Trujillo Relatório

0

length is not a function it is just Yourthings.length without (). more doc at length documentation

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda